//
//  ViewController.m
//  sssssssssssss
//
//  Created by paycloud110 on 16/1/14.
//  Copyright © 2016年 paycloud110. All rights reserved.
//

#import "ViewController.h"
#import "JWRichTextView.h"

@interface ViewController () <JWRichTextViewDelegate>



@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view .backgroundColor = [UIColor whiteColor];
    
    JWRichTextView *textView = [[JWRichTextView alloc] init];
    
    NSString *string = @"1.进入【系统设置】-->【蓝牙】页面，点点击点击击[111]设备\"iShuaShua\"右[222]边的标志2.进入后选择标志2.进入后选择标志2.进入[111]后选择标志2.进入后选择";
    
    // 计算文字高度
    CGRect rect = [textView boundingRectWithSize:CGSizeMake(300, MAXFLOAT) font:[UIFont systemFontOfSize:15] string:string rowSpace:1];
    
    textView.frame = CGRectMake(10, 111, rect.size.width, rect.size.height);
    textView.textColor = [UIColor darkGrayColor];
    textView.rowSpace = 1;
    textView.font = [UIFont systemFontOfSize:15];
    textView.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.5];
    textView.delegage = self;
    textView.text = string;
    
    [self.view addSubview:textView];
    
}

- (void)richTextView:(JWRichTextView *)view touchBeginRun:(JWRichTextRun *)run
{
    
}

- (void)richTextView:(JWRichTextView *)view touchEndRun:(JWRichTextRun *)run
{
    if ([run isKindOfClass:[JWRichTextRunURL class]])
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:run.text]];
    }
    
    NSLog(@"%@",run.text);
}

@end
